package com.yanmaohu.yulia.bean;

import java.util.List;

/**
 * @author Bright Lee
 */
public final class InputUsingClause {

    private int beginIndex;
    private int endIndex;
    private List<GeneralValueSpecification> usingArgumentList;
    private UsingDescriptor usingDescriptor;

    public InputUsingClause(int beginIndex,
                            List<GeneralValueSpecification> usingArgumentList) {
        this.beginIndex = beginIndex;
        this.endIndex = usingArgumentList.get(usingArgumentList.size() - 1).getEndIndex();
        this.usingArgumentList = usingArgumentList;
    }

    public InputUsingClause(UsingDescriptor usingDescriptor) {
        this.beginIndex = usingDescriptor.getBeginIndex();
        this.endIndex = usingDescriptor.getEndIndex();
        this.usingDescriptor = usingDescriptor;
    }

    public int getBeginIndex() {
        return beginIndex;
    }

    public int getEndIndex() {
        return endIndex;
    }

    public boolean isUsingArgumentListEmpty() {
        if (usingArgumentList == null) {
            return true;
        }
        return usingArgumentList.isEmpty();
    }

    public int usingArgumentListSize() {
        if (usingArgumentList == null) {
            return 0;
        }
        return usingArgumentList.size();
    }

    public GeneralValueSpecification getUsingArgument(int index) {
        return usingArgumentList.get(index);
    }

    public UsingDescriptor getUsingDescriptor() {
        return usingDescriptor;
    }

}
